package cn.fl.ref.fncprjbscinfo.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.ref.fncprjbscinfo.service.IFncPrjPayPlanService;
import cn.fl.ref.fncprjbscinfo.transform.FncPrjPayPlanVOTransform;
import cn.fl.ref.fncprjbscinfo.vo.FncPrjPayPlanVO;
import fl.ref.fncprjbscinfo.condition.FncPrjPayPlanQueryCondition;
import fl.ref.fncprjbscinfo.dto.FncPrjPayPlanDTO;
import fl.ref.fncprjbscinfo.service.IFncPrjPayPlanApiService;
/**
 * @Description: 项目还款计划
 * @Description:业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 * 服务实现层
 */
@Service
public class FncPrjPayPlanServiceImpl implements IFncPrjPayPlanService {

	private static final Logger logger = LoggerFactory.getLogger(IFncPrjPayPlanService.class);
	
	@Autowired
	private IFncPrjPayPlanApiService  fncPrjPayPlanApiService;

	@Override
	public FncPrjPayPlanVO selectById(Long id) throws BaseException {
		if(StringUtils.isEmpty(id)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		FncPrjPayPlanDTO dto = this.fncPrjPayPlanApiService.selectById(id);
		return FncPrjPayPlanVOTransform.toVO(dto);
	}

	@Override
	public Long add(FncPrjPayPlanVO entity) throws BaseException {
		if(null == entity){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		//系统日志-有用户的情况下
		BaseLogUtils.info(logger, "add", "新增FncPrjPayPlan数据.", CurrentThreadContext.getCurrentUserName());
		
		//系统日志-无用户的情况下
		BaseLogUtils.info(logger, "add", "新增FncPrjPayPlan数据.");
		return this.fncPrjPayPlanApiService.add(FncPrjPayPlanVOTransform.toDTO(entity));
	}

	@Override
	public boolean removeById(Long id) throws BaseException {
		if(StringUtils.isEmpty(id)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		return this.fncPrjPayPlanApiService.removeById(id);
	}

	@Override
	public boolean modify(FncPrjPayPlanVO entity) throws BaseException {
		if(null == entity){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		return this.fncPrjPayPlanApiService.modify(FncPrjPayPlanVOTransform.toDTO(entity));
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException {
		if(null == page)page = new Pager();
		return this.fncPrjPayPlanApiService.searchListPage(page);
	}
	

	@Override
	public List<FncPrjPayPlanVO> searchList(FncPrjPayPlanQueryCondition condition) {
		// TODO Auto-generated method stub
		return FncPrjPayPlanVOTransform.toVOList(this.fncPrjPayPlanApiService.searchList(condition))  ;
	}

	@Override
	public List<FncPrjPayPlanVO> selectchgr(Long id) throws BaseException {
		// TODO Auto-generated method stub
		return FncPrjPayPlanVOTransform.toVOList(this.fncPrjPayPlanApiService.selectchgr(id))  ;
	}	



}
